from django.db import models
from user.models import UserModel


class Friend(models.Model):
    # 申请者
    requester = models.ForeignKey(UserModel, on_delete=models.CASCADE, related_name='friend_requests_sent')
    # 接收者
    recipient = models.ForeignKey(UserModel, on_delete=models.CASCADE, related_name='friend_requests_received')
    # 接收状态
    status = models.IntegerField(default=0)

    def __str__(self):
        return f'{self.requester} -> {self.recipient}, Status: {self.status}'

    class Meta:
        db_table = "friends"  # 指明表名
        verbose_name = "好友表"  # 在admin站点显示名称